class TourImagesController < ApplicationController
  
  layout 'admin'

  # GET /tour_images
  # GET /tour_images.json
  def index
    @tour_images = TourImage.where('tour_id =?', params[:tid])
    @tour_image = TourImage.new

    respond_to do |format|
      format.js { render layout: false }
    end
  end

  # GET /tour_images/1
  # GET /tour_images/1.json
  def show
    @tour_image = TourImage.find(params[:id])

    respond_to do |format|
      format.js { render layout: false }
    end
  end

  # GET /tour_images/new
  # GET /tour_images/new.json
  def new
    @tour_image = TourImage.new

    respond_to do |format|
      format.js { render layout: false }
    end
  end

  # GET /tour_images/1/edit
  def edit
    @tour_image = TourImage.find(params[:id])
  end

  # POST /tour_images
  # POST /tour_images.json
  def create
    @tour_image = TourImage.new(params[:tour_image])
    if @tour_image.save
      @tour_id = @tour_image.tour_id
      @data_check = true
    else
      @data_check = false
    end

    respond_to do |format|
      format.js { render layout: false }
    end
  end

  # PUT /tour_images/1
  # PUT /tour_images/1.json
  def update
    @tour_image = TourImage.find(params[:id])
    @tour_image.update_attributes(params[:tour_image])

    respond_to do |format|
      format.js { render layout: false }
    end
  end

  # DELETE /tour_images/1
  # DELETE /tour_images/1.json
  def destroy
    @tour_image = TourImage.find(params[:id])
    if @tour_image.destroy
      @tr_id = @tour_image.id
      @data_check = true
    else
      @data_check = false
    end

    respond_to do |format|
      format.js { render layout: false }
    end
  end
end
